package com.qgs.waf.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qgs.waf.mapper.AlertlogMapper;
import com.qgs.waf.model.Alertlog;
import com.qgs.waf.service.ZbksAlertlogService;
import com.qgs.waf.util.JSonUtil;

@Service(value="zbksAlertlogServiceImpl")
public class ZbksAlertlogServiceImpl implements ZbksAlertlogService {

	@Autowired
	private AlertlogMapper alertlogMapper;
	
	@Override
	public String queryListByProvinceAndIndustry(Integer pn, Integer ps, String start, String end, String province, String industry, String status) {
		PageHelper.startPage(pn, ps);
		List<Map<String, Object>> cs = alertlogMapper.queryListByProvinceAndIndustry(start, end, province, industry, status);
		// 用PageInfo对结果进行包装
		PageInfo page = new PageInfo(cs);
		return JSonUtil.object2JSon(page);
	}

	@Override
	public Integer saveAlertlog(Alertlog alertlog) {
		alertlog.setCreateDate(new java.util.Date());
		return alertlogMapper.insert(alertlog);
	}

	@Override
	public Integer sendAlertLog(Alertlog alertlog) {
		Alertlog a = alertlogMapper.selectOne(alertlog);
		a.setStatus("0");
		return alertlogMapper.updateByPrimaryKey(a);
	}

}
